home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Oberon⁄F™ 1.2 / Preinstalled version / Obx / Docu / Controls (.txt) < prev    next >
Encoding:
Oberon Document  |  1995-08-09  |  6.5 KB  |  62 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. Helvetica
  17. Helvetica
  18. TextRulers.StdRulerDesc
  19. TextRulers.RulerDesc
  20. TextRulers.StdStyleDesc
  21. TextRulers.StyleDesc
  22. TextRulers.AttributesDesc
  23. DevCommanders.StdViewDesc
  24. DevCommanders.ViewDesc
  25. StdLinks.LinkDesc
  26. StdCmds.OpenDoc('Obx/Mod/Controls')
  27. Helvetica
  28. Oberon by Example: ObxControls
  29. In Release 1.1, several controls have been added, e.g. list boxes. At the same time, the behavior of controls has been made more flexible: the change of an interactor field (i.e. a field of a globally declared record variable) can now affect not only controls which are linked to this field, but others as well. For example, a command button may be disabled as long as a text field is empty, and become enabled immediately after something is typed into the text field.
  30. Guard commands
  31. Such state changes of controls, which are the results of state changes in an interactor, are handled by guard commands. A guard is a command which may disable a control, may denote it as undefined, or may make it read-only. It does not have other side effects; in particular, it doesn't invoke an arbitrary action or change the state of an interactor. For that purpose, notifiers have been introduced.
  32. Notifier commands
  33. A notifier is an optional command sequence which can be bound to a control, using the control property editor (-> DevInspector). For example, a notifier command may write something into the status bar of a window when the mouse button is pressed, and clear the status bar when the mouse button is released again.
  34.     It is more typical, however, that a notifier changes the state of the interactor to which its control is linked; i.e. to change one or more of the interactor fields to which its control is not linked.
  35.      In this way, the change of one interactor field's value may cause a change of another field's value, via the former's notifier.
  36. Example
  37. The example illustrates guards and notifiers, as well as command button, radio button, and list box controls.
  38.     Imagine something whose size should be controlled via a dialog, with more skilled users getting more degrees of freedom. For example, this may be a dialog for a game, which allows the user to choose a skill level. A novice user only gets a default amount of money to invest in an economics simulation game, a more experienced user additionally may choose among three predefined choices, while a guru may enter any value he or she wants to use. In order to keep our example simple and to concentrate on the control behaviors, nothing as complex as a simulation game is implemented. Instead, the initial size of a square view can be controlled by the user, in a more or less flexible way that depends on the chosen skill level.
  39.     In our example, the skill level is implement as the class field of the data interactor in module ObxControls. It is an integer variable, to which a text entry field may be linked, or more appropriately, a number of radio buttons. The radio buttons are labeled beginner, advanced, expert, and guru. Depending on the currently selected class, the interactor's list field (a specialized enumeration) is adapted: for a beginner, the list box should be disabled, because there is no choice (the default is taken). For an advanced player, a choice between "small", "medium", and "large" are presented in addition to the "default" size. Obviously, the list box must be enabled if such a choice exists. "expert" players get even more choices, namely "tiny" and "huge". Note that if these choices appear, the list box becomes too small to show all choices simultaneously. As a consequence, the scroll bar of the list box becomes enabled.
  40.     "guru" players have even more freedom, they can type in the desired size numerically, in a text entry field which is read-only for all other skill levels. The command button Cancel closes the dialog without doing anything, the Open button starts the game, and the OK button starts the game and immediately closes the dialog in addition.
  41. Since we are mainly interested in how to implement the described behavior, we don't actually implement a game. Instead, the "game" merely consists in opening a new view, whose size is determined by the size chosen in the dialog (default, large, small, etc.)
  42. With the New Form... menu command, a new dialog box for the ObxControls.data interactor can be created automatically. The layout of this dialog can be edited interactively, and the properties of the various controls can be set using the control property editor. They should be set up as in the table below:
  43. Control    Link    Label    Guard    Notifier    Level
  44. Radio Button    ObxControls.data.class    &Beginner        ObxControls.ClassNotify    0
  45. Radio Button    ObxControls.data.class    &Advanced        ObxControls.ClassNotify    1
  46. Radio Button    ObxControls.data.class    &Expert        ObxControls.ClassNotify    2
  47. Radio Button    ObxControls.data.class    &Guru        ObxControls.ClassNotify    3
  48. List Box    ObxControls.data.list        ObxControls.ListGuard    ObxControls.ListNotify
  49. Text Field    ObxControls.data.width        ObxControls.WidthGuard
  50. Command Button    StdCmds.CloseDialog;
  51.     ObxControls.Open    OK
  52. Command Button    ObxControls.Open    &Open
  53.  "StdCmds.OpenAuxDialog('Obx/Rsrc/data', 'ObxControls Demo')"
  54. ObxControls
  55. sources
  56. TextControllers.StdCtrlDesc
  57. TextControllers.ControllerDesc
  58. Containers.ControllerDesc
  59. Controllers.ControllerDesc
  60. Helvetica
  61. Documents.ControllerDesc
  62.